package org.zjh.controller.listener;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * 程序退出监听
 */
public class ExitLis extends WindowAdapter {
    private static final ExitLis exitLis = new ExitLis();

    private ExitLis(){}

    @Override
    public void windowClosing(WindowEvent e) {
        int choice = JOptionPane.showConfirmDialog(null, "是否关闭", "温馨提示", JOptionPane.YES_NO_OPTION);
        if (choice == 0){
            System.exit(0);
        }
    }

    public static ExitLis getInstance() {
        return exitLis;
    }
}